import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: wangxin
 * Date: 2024-12-30
 * Time: 22:34
 */
public class Test {
//    public static void main(String[] args) {
//        Stack<Integer> stack1 = new Stack<>();
//        LinkedList<Integer> stack2 = new LinkedList<>();
//        Deque<Integer> stack3 = new LinkedList<>();
//        stack1.push(1);
//        stack1.push(2);
//        stack1.push(3);
//        stack2.push(10);
//        stack2.push(20);
//        stack2.push(30);
//        stack3.push(11);
//        stack3.push(22);
//        stack3.push(33);
//        System.out.println("======基于数组实现的栈======");
//        System.out.println(stack1.peek());
//        System.out.println(stack1.pop());
//        System.out.println(stack1.peek());
//        System.out.println("======基于链表实现的栈======");
//        System.out.println(stack2.peek());
//        System.out.println(stack2.pop());
//        System.out.println(stack2.peek());
//        System.out.println("======基于双向队列实现的栈======");
//        System.out.println(stack3.peek());
//        System.out.println(stack3.pop());
//        System.out.println(stack3.peek());
//    }
public static void main(String[] args) {
    MyStack<Integer> s = new MyStack<>();
    s.push(1);
    s.push(2);
    s.push(3);
    s.push(4);
    System.out.println("size: "+s.size()); // 获取栈中有效元素个数---> 4
    System.out.println(s.peek()); // 获取栈顶元素---> 4
    s.pop(); // 4出栈，栈中剩余1 2 3，栈顶元素为3
    System.out.println(s.pop()); // 3出栈，栈中剩余1 2 栈顶元素为3
    if(s.empty()){
        System.out.println("栈空");
    }else{
        System.out.println("size: "+s.size());
    }
}
}
